package logic

import (
	"context"
	"video/mysql/model"

	"video/videorpc/internal/svc"
	"video/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoAddLogic {
	return &VideoAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 视频上传
func (l *VideoAddLogic) VideoAdd(in *videorpc.VideoAddRequest) (*videorpc.VideoAddResponse, error) {
	// todo: add your logic here and delete this line

	video := model.Video{
		Title:       in.Title,
		VideoClass:  in.VideoClass,
		Image:       in.Image,
		Info:        in.Info,
		UserId:      in.UserId,
		VideoStatus: in.VideoStatus,
	}
	model.DB.Debug().Create(&video)

	return &videorpc.VideoAddResponse{
		VideoId: int64(video.ID),
	}, nil
}
